// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

// 云函数入口函数
exports.main = async (event, context) => {
  try {
    console.log(event)
    const result = await cloud.openapi.subscribeMessage.send({
      touser: event.id.openid,
      lang: 'zh_CN',
      data: {
        thing1: {
          value: event.category
        },
        phone_number4: {
          value: event.telephone
        },
      },
      templateId: 'MzoHDjYDm_45bJ7t_9XNQGhMqPhv25Co8mAfLGPZgAA',
      miniprogramState: 'trial'
    })
    console.log(result)
    console.log("success")
    return result
  } catch (err) {
    console.log(err)
    return err
  }
}